package com.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration //配置类
@EnableSwagger2// 开启Swagger2的自动配置
public class SwaggerConfig {

    @Bean
    public Docket docket(Environment environment){

        //设置要显示的swagger环境
       // Profiles profiles=Profiles.of();
        //获取swagger的环境
       // Boolean flag=environment.acceptsProfiles(profiles);
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("Controller")
                .apiInfo(apiInfo())
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.demo.controller"))
                .build();
    }
    //配置swagger信息
    private ApiInfo apiInfo(){
        //作者的信息
        Contact contact= new Contact("XX","http://www.apache.org/licenses/LICENSE-2.0","1360827125@qq.com");
        return new ApiInfo("医疗小组的API文档",
                "真本领做事，高品质做人",
                "1.0",
                "urn:tos",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}
